package List;

import java.util.HashSet;
import java.util.Set;
import java.util.TreeSet;

public class SetTest {
    public static void main(String[] args) {
        TreeSet<Student> students = new TreeSet<>((o,o1)->{
            int i=o.getId()-o1.getId();
            int i1=o.getName().hashCode()-o1.getName().hashCode();
            return i==0?i1:i;
        });
        students.add(new Student(1,"李华"));
        students.add(new Student(12,"李华"));
        students.add(new Student(2,"李华"));
        for (Student student : students) {
            System.out.println(student.toString());
        }
    }
}
